package com.example.boxuegu;


import android.content.Intent;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
    public static String md5(String text){
        MessageDigest digest=null;
        try {
            digest=MessageDigest.getInstance("md5");
            byte[] result=digest.digest(text.getBytes());
            StringBuilder stringBuilder = new StringBuilder();
            for(byte b:result){
                int number=b&0xff;
                String he = Integer.toHexString(number);
                if(he.length()==1){
                    stringBuilder.append("i"+he);
                }else{
                    stringBuilder.append(he);
                }
            }
            return stringBuilder.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return "";
        }

    }
}
